﻿using Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Tools;
using 纺织贸易管理系统;
using 纺织贸易管理系统.其他窗体;

namespace 后整理管理系统.新增窗体
{
    public partial class 新增公司 : Sunny.UI.UIForm
    {
        private info Company=new info ();   
        private FormUseful useful= new FormUseful ();
        public 新增公司(info company,FormUseful useful )
        {
            InitializeComponent();
            this.Company = company;
            this.useful = useful;
            txtAddress.Text=company.Address;
            txtBankName.Text=company.BankName;
            txtBankNum.Text=company.BankNum;
            txtCompanyName.Text  = company.gsmc;
            txtTel.Text = company.GHSMC;
            txtTax.Text =company.TaxNum ;
            txtEmail.Text = company.Email;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                Company.gsmc = txtCompanyName.Text;
                Company.BankNum = txtBankNum.Text;
                Company.BankName = txtBankName.Text;
                Company.Address = txtAddress.Text;
                Company.TaxNum = txtTax.Text;
                Company.GHSMC = txtTel.Text;
                Company.Email = txtEmail.Text;
                if (useful == FormUseful.新增)
                {
                    infoService.Insertinfo(this.Company);
                }
                else
                {
                    infoService.Updateinfo(this.Company);
                }
                AlterDlg.Show("操作完成");

                this.Close();
            }
            catch(Exception ex)
            {
                ShowMessageBox.ShowErrorBox(ex.Message);
            }
        }
    }
}
